package com.hzcx.app.simplechat.ui.setting;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.base.BaseActivity;
import com.hzcx.app.simplechat.ui.setting.contract.AddAutoSendMsgContract;
import com.hzcx.app.simplechat.ui.setting.event.AddAutoSendMsgEvent;
import com.hzcx.app.simplechat.ui.setting.presenter.AddAutoSendMsgPresenter;
import com.hzcx.app.simplechat.util.empty.EmptyUtils;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 添加自动回复-文本
 */
public class AddAutoSendMsgTextActivity extends BaseActivity<AddAutoSendMsgPresenter> implements AddAutoSendMsgContract.View {

    public static final String INTENT_ID = "INTENT_ID";
    public static final String INTENT_CONTENT = "INTENT_CONTENT";

    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.iv_title_right)
    ImageView ivTitleRight;
    @BindView(R.id.tv_title_right)
    TextView tvTitleRight;
    @BindView(R.id.et_content)
    EditText etContent;

    private String id;

    @Override
    public int getLayout() {
        return R.layout.activity_add_auto_send_msg;
    }

    @Override
    public void initPresenter() {
        mPresenter = new AddAutoSendMsgPresenter();
    }

    @Override
    public void initView() {
        tvTitle.setText("文字内容");
        tvTitleRight.setText("完成");
    }

    @Override
    public void initData() {
        id = getIntent().getStringExtra(INTENT_ID);
        if (EmptyUtils.isNotEmpty(getIntent().getStringExtra(INTENT_CONTENT))) {
            etContent.setText(getIntent().getStringExtra(INTENT_CONTENT));
        }
    }

    @OnClick({R.id.tv_title_right})
    public void viewOnClick(View view) {
        switch (view.getId()) {
            case R.id.tv_title_right:
                mPresenter.addAutoChatMessage(this, 1, etContent.getText().toString(), null, id);
                break;
        }
    }

    /**
     * 添加成功
     */
    @Override
    public void addSuccess() {
        EventBus.getDefault().post(new AddAutoSendMsgEvent());
        showError("添加成功");
        finish();
    }

    @Override
    public void imgLoadResult(String url) {

    }
}
